package com.tkafka.confgi;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/5/24  16:17
 * 描述:
 */
@Component
public class MyKafkaListener {

    @KafkaListener(topics = {"HHHH"},containerFactory = "myKafkaListenerContainerFactory",groupId = "TT")
    public void getMessage(ConsumerRecord<String,String> record, Acknowledgment acknowledgment){

        System.out.println("========获取====消息内容==="+record.value());

        System.out.println("========获取====消息唯一标识Key==="+record.key());

        /*if(record.topic().equals("HHHH")){
            //业务处理1
        }else if(record.topic().equals("XXXX")){
            //业务处理2
        }*/

        //进行消息的确认提交
        acknowledgment.acknowledge();


    }

}
